/******************************************************************************
/// @brief
/// @copyright Copyright (c) 2017 <dji-innovations, Corp. RM Dept.>
/// @license MIT License
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction,including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense,and/or sell
/// copies of the Software, and to permit persons to whom the Software is furnished
/// to do so,subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
*******************************************************************************/

#ifndef __CHASSIS_H__
#define __CHASSIS_H__

#include "mytype.h"
#include "stm32f4xx_hal.h"

typedef enum {

    CHASSIS_STOP, // stall
    CHASSIS_RELAX, // relax
    CHASSIS_OPEN_LOOP,
    CHASSIS_CLOSE_GYRO_LOOP,
    CHASSIS_FOLLOW_GIMBAL_ENCODER,

} chassis_mode_e;

typedef struct
{
    // float my_normal_speed;   //底盘合速度
    float           vx; // x分速度	forward/back
    float           vy; // y分速度	left/right
    float           omega; // w角速度  to calc matrix, target omega
    float           kb_vx;
    float           kb_vy;
    float           mouse_omega;
    chassis_mode_e  mode;
    chassis_mode_e  last_mode;
    float           target_angle; //地盘目标角度
    float           angle_from_gyro;
    float           omega_from_gyro; // measure omega
    float           last_angle;
    data_convert_ut angle_from_gimbal;
    int             is_snipe_mode; //	1 = yes 0 = no	// gimbal & chassis seperate
    /*new add*/
    data_convert_ut wheel_speed;
} chassis_t; //底盘状态

void             reset_zgyro(void); // after call, at least wait 2s
void             chassis_task(void const*);
extern chassis_t chassis;

#endif
